﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OpenSoftStore.BusinessLogic.Common;
using OpenSoftStore.Orm.Model;
using OpenSoftStore.Client.Common;
using OpenSoftStore.BusinessLogic.Set;

namespace OpenSoftStore.Client.UIL.ManageSet
{
    public partial class ShopList : UserControl
    {
        private TreeLogic lgcTree;
        private static ShopList instance;
        public static ShopList Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new ShopList();
                }
                return instance;
            }
        }
        public ShopList()
        {
            InitializeComponent();
            this.Dock = DockStyle.Fill;
            lgcTree = new TreeLogic();
            GetDgvSource();
            SPACommon.SetDataGridStyle(DgvGrid);
        }
        public void GetDgvSource()
        {
            if (DgvGrid != null)
            {
                DgvGrid.AutoGenerateColumns = false;
                var set = new SetLogic();
                DgvGrid.DataSource = set.Where<T_Shop>(null);
            }
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (DgvGrid.CurrentRow == null) return;
            var id = DgvGrid.CurrentRow.Cells["Id"].Value.ToString();
            ShopAddWindow shopaddWindow = new ShopAddWindow();
            shopaddWindow.GetId(id);
            shopaddWindow.Show();
        }
    }
}
